/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.rcnss.ui.table.handler;
import com.rcnss.ui.form.UsersListForm;
import com.vaadin.event.Action;
import com.vaadin.event.Action.Handler;
import com.vaadin.event.ItemClickEvent;
import com.vaadin.event.ItemClickEvent.ItemClickListener;
import com.vaadin.ui.Table;
import com.vaadin.ui.Window;

/**
 *
 * @author Guesmi
 */
public class ReclamtionAssignedActionHandler implements Handler{

    private Action ACTION_ASSIGN = new Action("Affecter a...");

    public Action[] getActions(Object target, Object sender) {
        return new Action[] {ACTION_ASSIGN};
    }

    public void handleAction(Action action, final Object sender, Object target) {
        if(action.equals(ACTION_ASSIGN))
        {
            final Object id = null;
            //((Table)sender).removeItem(target);
            final Window w = new Window("Affecter a ...");
            w.setModal(true);
            w.setWidth("450px");
            UsersListForm u = new UsersListForm();
            u.table.removeAllActionHandlers();
            //u.table.removeListener(u.itemClickListener);
            u.table.addListener(new ItemClickListener() {

                public void itemClick(ItemClickEvent event) {
                    ((Table)sender).getWindow().removeWindow(w);
                }
            });
            u.body.replaceComponent(u.splitPanel, u.table);
            w.addComponent(u);
            ((Table)sender).getWindow().addWindow(w);

        }
    }
}
